package com.tanglongan.designPattern.dp17_memento.demo01;

public class Client {

    public static void main(String[] args) {
        DraftsBox box = new DraftsBox();
        Editor editor = new Editor("设计模式应该这样学", "多思考多练手", "436dheuw2343fjierjiofkerog.png");

        ArticleMemento articleMemento = editor.saveToMemento();
        box.addMemento(articleMemento);
        System.out.println("标题：" + editor.getTitle() + "\n内容：" + editor.getContent() + "\n插图：" + editor.getImgs() + "\n 暂存成功");

        System.out.println("================第1次保存草稿==================");
        articleMemento = editor.saveToMemento();
        box.addMemento(articleMemento);
        System.out.println("完整的信息：" + editor);
        System.out.println("================第1次修改完成==================\n");

        System.out.println("================第2次修改文章==================");
        editor.setTitle("大话设计模式");
        editor.setContent("设计模式是每个工程的基本功");
        editor.setImgs("26143ubfrjegi4rgrtjgbrt.jpg");
        articleMemento = editor.saveToMemento();
        box.addMemento(articleMemento);
        System.out.println("完整的信息：" + editor);
        System.out.println("================第2次修改完成==================\n");

        System.out.println("================第1次撤回文章==================");
        articleMemento = box.getMemento();
        editor.undoFromMemento(articleMemento);
        System.out.println("完整的信息：" + editor);
        System.out.println("================第1次撤回完成==================\n");

        System.out.println("================第2次撤回文章==================");
        articleMemento = box.getMemento();
        editor.undoFromMemento(articleMemento);
        System.out.println("完整的信息：" + editor);
        System.out.println("================第2次撤回完成==================\n");

    }
}
